package com.tarena.lbs.business.pojo.po;

import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.*;
import org.springframework.data.elasticsearch.core.geo.GeoPoint;


@Data
@Setting(shards = 1, replicas = 0)
@Document(indexName = "stores", createIndex = true)
public class StoreSearchPO {
    @Id
    private Integer id;

    private String location;
    @Field(type = FieldType.Text)
    private String storeName;
    private Integer businessId;
    @GeoPointField
    private GeoPoint geoPoint;
    public void setGeoPoint(String storeLatitude, String storeLongitude) {
        try {
            double lat = Double.parseDouble(storeLatitude);
            double lon = Double.parseDouble(storeLongitude);
            this.geoPoint = new GeoPoint(lat, lon);
        } catch (NumberFormatException e) {

        }
    }
}

